package com.itheima.controller;

import com.itheima.common.R;
import com.itheima.pojo.Dish;
import com.itheima.pojo.Setmeal;
import com.itheima.service.SetmealService;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource;
import java.util.List;

/**
 * @author Envy
 */
@RestController
@RequestMapping("/setmeal")
public class SetmealController {
    @Resource
    private SetmealService setmealService;

    /**
     * 菜品详情
     */
    @GetMapping("/dish")
    public R<Dish> selectDetails() {
        return setmealService.selectDetails();
    }

    /**
     * 套餐列表
     */
    @GetMapping("/list")
    public R<List<Setmeal>> selectDetails(@RequestParam String categoryId, @RequestParam Integer status) {
        List<Setmeal> setmeals = setmealService.selectDetails(categoryId, status);
        if (setmeals != null) {
            return R.success(setmeals);
        }
        return R.error("暂无数据");
    }
}
